package com.company.huisuo.biz.adapter

import android.app.Activity
import android.view.LayoutInflater
import android.view.ViewGroup
import com.company.huisuo.base.BaseSingleAdapter
import com.company.huisuo.biz.bean.ArtistBean
import com.company.huisuo.biz.dialog.FeedBackInputDialog
import com.company.huisuo.databinding.ItemFeedbackBinding
import com.company.huisuo.ext.loadCircleImg
import com.company.huisuo.ext.loadImg
import com.lxj.xpopup.XPopup


class FeedBackAdapter : BaseSingleAdapter<ArtistBean, ItemFeedbackBinding>() {

    override val initViewBinding: (LayoutInflater, ViewGroup, Boolean) -> ItemFeedbackBinding
        get() = ItemFeedbackBinding::inflate

    override fun convert(holder: SingleViewHolder<ItemFeedbackBinding>, position: Int, item: ArtistBean?) {
        holder.binding.ivAvatar.loadCircleImg(item?.avatar ?: 0)
        holder.binding.tvName.text = item?.name
        holder.binding.tvFeedback.setOnClickListener {
            XPopup.Builder(context)
                .moveUpToKeyboard(false)
                .asCustom(FeedBackInputDialog(context as Activity)).show()
        }
    }
}